package com.gaowl.gulimall.product.entity;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import java.io.Serializable;

import com.gaowl.common.valid.ListValue;
import com.gaowl.common.valid.AddGroup;
import com.gaowl.common.valid.UpdateGroup;
import lombok.Data;
import org.hibernate.validator.constraints.URL;

import javax.validation.constraints.*;

/**
 * 品牌
 * 默认情况下，没有指定指定分组的校验注解，将不会生效，它只会在不分组的情况下生效。
 * 
 * @author gaowl
 * @email gaowl@stu.jiangnan.edu.cn
 * @date 2021-03-11 11:39:16
 */
@Data
@TableName("pms_brand")
public class BrandEntity implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 * 品牌id
	 */
	@TableId
	@Null(message = "添加时品牌id必须为空",groups ={AddGroup.class} )
	@NotNull(message = "修改时品牌id不能为空",groups = {UpdateGroup.class})
	private Long brandId;

	/**
	 * 品牌名，在更新和添加时均需进行校验
	 */
	@NotBlank(message = "品牌名必须非空", groups = {UpdateGroup.class, AddGroup.class})
	private String name;

	/**
	 * 品牌logo地址
	 */
	@URL(message = "您所提交的品牌logo的地址不是有效网址",groups = {AddGroup.class, UpdateGroup.class})
	private String logo;

	/**
	 * 介绍
	 */
	private String descript;

	/**
	 * 显示状态[0-不显示；1-显示]
	 */
	@NotNull(message = "显示状态不能为空", groups = {AddGroup.class, UpdateGroup.class})
	@ListValue(values = {0,1}, groups ={AddGroup.class})   // 必须为0或1，错误消息也可以通过message设定，且优先级更高
	private Integer showStatus;

	/**
	 * 检索首字母
	 */
	@NotBlank(message = "检索首字母不可为空", groups = {AddGroup.class, UpdateGroup.class})
	@Pattern(regexp = "^[a-zA-Z]$", message = "检索字符必须是一个字母",
			groups = {AddGroup.class, UpdateGroup.class})
	private String firstLetter;

	/**
	 * 排序
	 */
	@NotNull(message = "排序字段不可为空", groups = {AddGroup.class,UpdateGroup.class})
	@Min(value = 0, message = "排序字段必须大于等于0")
	private Integer sort;

}
